<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品信息</title>
<%@ include file="../../header_inc.jsp"%>


</head>

<body class="easyui-layout">
<div data-options="region:'north',border:false"	style="height: 0px; background: #EEEEEE; padding: 5px">
   	<div id="tb" style="padding:5px;height:auto">
		<form method="post" id="formModule">
		<div>
			Date From: <input class="easyui-datebox" style="width:80px" name="beginTime">
			To: <input class="easyui-datebox" style="width:80px" name="endTime">
			商品名:<input class="easyui-validatebox textbox" style="width:80px" name="name">
			商品的类别:<select id="ppp" class="easyui-combotree"
					 url="http://localhost:8080/shoeHouse/commodifyCategory/treeView" 
					 name="categoryId" style="width:156px; ">
					
					</select>
		
			<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="searchit()">Search</a>
		</div>
		</form>
	</div>
	</div>
	<div data-options="region:'north',border:false" style="height:0px;background:#EEEEEE;padding:0px"></div> 
	<div data-options="region:'center',title:''">
	<table id="dg" title="商品信息"   style="width:700px;height:250px" data-options="
				rownumbers:true,
				singleSelect:true,
				autoRowHeight:false,
				fit:true,
				pagination:true,
				pageSize:10,
				url:'http://localhost:8080/shoeHouse/commodifyInfo/view',
				method:'get',
				idField:'id',
				toolbar:'#toolbar',
				onDblClickRow: function (rowIndex, rowData) { 
				view(rowIndex,rowData);
				
				}">
		<thead>
			<tr>
			<th data-options="field:'ck',checkbox:true"></th>
			    <th field="id" width="150" align="center">编号</th>
				<th field="name" width="120" align="center">商品名</th>
				<th field="account" width="100" align="center">商品描述</th>
				<th field="price" width="80"  align="center">价格</th>
				<th field="commodityCategory" width="80"  align="center" formatter="formatCategory">类别</th>
				<th field="inventoryNum" width="80"  align="center">库存</th>
				<th field="userInfo" width="80"  align="center" formatter="formatUser">创建者</th>
				<th field="orderNum" width="100" align="center">订单数</th>
				<th field="gmtCreate" width="150" align="center" formatter="formatDate">创建的时间</th>
				<th field="gmtModified" width="150" align="center" formatter="formatDate">更改的时间</th>
				<th field="browseNum" width="110" align="center">浏览次数</th>
			</tr>
		</thead>
	

	</table>
	
	<div id="toolbar" style="height: auto">
	<div style="margin:10px 0;">
	<select onchange="$('#dg').datagrid({singleSelect:(this.value==0)})">
			<option value="0">Single Row</option>
			<option value="1">Multiple Rows</option>
		</select><br/>
	</div>
		<div style="margin-bottom:5px">
		<a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="append()"></a>

			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="edit()"></a>
		
			
			<a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeit()"></a>
		</div>
		</div>
	</div>


		<div id="dlgwindow">	</div>



	<script>
	function formatCategory(value){
		
        return value.name;

    };
	function formatUser(value){
		
		        return value.name;
		
		    };
   
		$(function(){
			if ($('#dg') != null) {
				$('#dg').datagrid({
					view: myview,
			        emptyMsg: '<span style="color:gray;font-weight:bold">没有查询到相关记录！</span>',
					onLoadSuccess : function(data) {
						if (data.success != 0) {
							//showErrMsg(data);
						}
					}
				});
			}
			/* $('#dg').datagrid({loadFilter:pagerFilter}); */
		});  
	</script> 
	<script type="text/javascript">

	function append() {
		/* $('#dlgwindow').dialog({
		    title: 'My Dialog',
		    width: 400,
		    height: 500,
		    closed: false,
		    cache: false,
		    href: '/shoeHouse/commodifyInfo/add',
		    modal: true
		}); */
	     
	     var content = '<iframe src="' + "/shoeHouse/commodifyInfo/add" + '" width="100%" height="99%" frameborder="0" scrolling="auto"></iframe>';
	$("#dlgwindow").dialog({
		    content: content,
			title: '我的对话框', //标题
			collapsible:true, //是否可折叠
			minimizable:true, //最小化按钮
			maximizable:true,//最大化按钮
			resizable:true,//是否改变窗口大小
			width: 500, 
			height: 400, 
			closed: false, 
			cache: false, 
		
			}); 
 
	
	}
	function view(rowIndex, rowData){
		var content="商品名:"+rowData.name+"</br></br>"
		+"商品内容:"+rowData.account+"</br></br>"
		+"地址:"+rowData.address+"</br></br>"
	+"商品价格："+rowData.price+"</br></br>"
	+"商品的鞋号:"+rowData.shoeSize+"</br></br>" 
		+"创建的时间："+formatDate(rowData.gmtCreate)+"</br></br>"
		+"库存："+rowData.inventoryNum+"</br></br>"
		+"更改的时间："+formatDate(rowData.gmtModified)+"</br></br>"
		+"订单数："+rowData.orderNum+"</br></br>"
		+"浏览次数："+rowData.browseNum+"</br></br>"
		+"商品的描述："+rowData.commodifyDexc+"</br></br>" 
		
		 +"商品照片:<img src='"+rowData.picture+"' width='100'height='100' /></br></br>"
		;
		  $("#dlgwindow").dialog({
			    content: content,
				title: '我的对话框', //标题
				collapsible:true, //是否可折叠
				minimizable:true, //最小化按钮
				maximizable:true,//最大化按钮
				resizable:true,//是否改变窗口大小
				width: 500, 
				height: 400, 
				closed: false, 
			
				}); 
		
	}
	
	function edit() {
		 	var id=0;
	        var name=null;
	        var row = $('#dg').datagrid('getSelected');
	    	var len = $('#dg').datagrid('getSelections').length; 	
	       	if(len>1){
	       		$.messager.alert("提示","只能选择一个进行更改!");
	       	}
	       	else if(len==1 && row)
	        {
	            id = row.id;
	            name = row.name;
	       /*      $('#dlgwindow').dialog({
	    		    title: 'My Dialog',
	    		    width: 400,
	    		    height: 500,
	    		    closed: false,
	    		    cache: false,
	    		    href: '/shoeHouse/commodifyInfo/edit?id='+id,
	    		    modal: true
	    		}); */
	           var content = '<iframe src="' + "/shoeHouse/commodifyInfo/edit?id="+id + '" width="100%" height="99%" frameborder="0" scrolling="auto"></iframe>';
			      $("#dlgwindow").dialog({
				    content: content,
					title: '我的对话框', //标题
					collapsible:true, //是否可折叠
					minimizable:true, //最小化按钮
					maximizable:true,//最大化按钮
					resizable:true,//是否改变窗口大小
					width: 500, 
					height: 400, 
					closed: false, 
				
					});  
	        }           
	        else
	        {
	            $.messager.alert("提示","请选择要修改的信息!");
	        }
	}
	
	function removeit() {
		var ids = [];
		var rows = $('#dg').datagrid('getSelections');
		var len = $('#dg').datagrid('getSelections').length; 
		for(var i=0; i<rows.length; i++){
			ids.push(rows[i].id);
		}
	    if(!len)
	    {
	        $.messager.alert("提示","请选择要移除的数据！");
	    }
	    else
	    {
	        $.messager.confirm("移除确认","是否要移除你选择的数据到回收站？",function(conf){
	            if(conf)
	            {
	            	alert(ids);
	                var url = "/shoeHouse/commodifyInfo/remove?ids="+ids;
	                $.getJSON(url, function(json){
	                    if(json.success==0)
	                    {
	                    	
	                    	$('#dg').datagrid('uncheckAll');
	                        $('#dg').datagrid('reload');
	                    }
	                    else
	                    {
	                        showErrMsg(json);
	                    }
	                });
	            }                                       
	        });
	    }
	}
	
	function deleteit() {
		var ids = [];
		var len = $('#dg').datagrid('getSelections').length; 
		var rows = $('#dg').datagrid('getSelections');
		for(var i=0; i<rows.length; i++){
			ids.push(rows[i].id);
		}
	    if(!len)
	    {
	        $.messager.alert("提示","请选择要删除的数据！");
	    }
	    else
	    {	
	        $.messager.confirm("删除确认","是否要删除你选择的数据？",function(conf){
	            if(conf)
	            {	
	            
	                var url = "${ctx}/manage/sysUsers/delete?ids="+ids;
	                $.getJSON(url, function(json){
	                    if(json.success==0)
	                    {
	                    	$('#dg').datagrid('uncheckAll');
	                        $('#dg').datagrid('reload');
	                    }
	                    else
	                    {
	                    	$.messager.alert("删除失败",json.msg);
	                    }
	                });
	            }                                       
	        });
	    }
	}
	
	function searchit() {
		$("#dg").datagrid("load", sy.serializeObject($('#formModule').form()));
	}
	//格式化日期
	function formatDate (strTime) {
	    var date = new Date(strTime);
	    return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
	}
	
	 function showIcon(value,rec,index)
     {
     	if(value != null && value != '')
     	{
     		return "<img src='"+ value +"' width='30' height='30' />";
     	}
     	else
     	{
     		return "";
     	}
     } 
	//角色格式化function depName(r){ return r.depName; }
	 function showRole(value,rec,index)
	 {
	 	if(value == "" || value == null)
	 	{
	 		return "<font color='blue'></font>";
	 	}
	 	else
	 	{
	 		return "<font color='green'>"+value.roleName+"</font>";
	 	}
	 	

	 }
	
	</script>
</body>
</html>